package com.example.douyin.demo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.example.douyin.R;
import com.example.douyin.db.DBUtils;
import com.example.douyin.db.UserInfo;

import java.util.List;

public class DemodbActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demodb);
    }

    public void add(View view) {
        DBUtils.getInstance().getUserDao().insertUser(new UserInfo("何乾坤",18));
        DBUtils.getInstance().getUserDao().insertUser(new UserInfo("冯子瑜",19));
    }
    public void query(View view) {
        List<UserInfo> infos = DBUtils.getInstance().getUserDao().queryUser("何乾坤");
        for (UserInfo info : infos) {
            Log.d("sss", "query: name:"+info.getName()+"age:"+info.getAge());
        }
    }
    public void delete(View view) {
        List<UserInfo> infos = DBUtils.getInstance().getUserDao().queryUser("何乾坤");
        DBUtils.getInstance().getUserDao().deleteUser(infos.get(0));
    }
}